package cn.hk.controller;

import cn.HK.po.User;
import cn.HK.vo.SystemResult;
import cn.hk.service.RegistService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.RestController;

@RestController
@RequestMapping("/user")
public class RegistController {
    @Autowired(required = false)
    private RegistService registService;
     /*用户注册
        请求地址:/user/regist
        请求方式:post
        请求参数:User user
        返回结果:SystemResult
        */

    @RequestMapping(value = "/regist",method = RequestMethod.POST)
    public SystemResult doRegist(User user){
        try{
            System.out.println(user);
            registService.doRegister(user);
            return SystemResult.ok();
        }catch (Exception e){
            e.printStackTrace();
            return SystemResult.build
                    (201, "注册用户失败", null);
        }
    }
}

